import React,{useEffect,useState} from 'react'
import {Route,Link} from 'react-router-dom'
import Styles from './index.module.less'
import {getParams} from '../../../utils/getParams'
import {welcome} from '../../../service/index'
 const Shop=(props)=> {
 const [shop, setShop] = useState({})
 const [userInfo, setUserInfo] = useState({})
     useEffect(() => {
// console.log(getParams('userId'))
        //  请求商铺信息
       welcome.getShopDatas({id:getParams('shopId')}).then(res=>{
           setShop(res.data)
       })
    //    请求用户信息
    welcome.getUserInfos({id:getParams('userId')}).then(res=>{
        setUserInfo(res.data)
    })
     }, [])

    return (
        <div className={Styles.shop}>
           <h2>
    <span>{shop.shop_name}</span>
           </h2>

    <section>欢迎光临，{userInfo.nickname}</section>
           <Link to="/welcome/selectPeople" className={Styles.btn}>开始点餐结账</Link>
        </div>
    )
}
const RenderRoute = ()=>{
    return <Route path="/welcome/shop"  component={Shop} />
}
export default RenderRoute
